package gui.applets;

import java.applet.Applet;
import java.awt.Button;
import java.awt.Choice;
import java.awt.Event;
import java.awt.TextField;

public class AppletChoice extends Applet {

	String[] desc = { "Ebullient", "Obtuse", "REcalcitrant" };

	TextField tf = new TextField(30);
	Choice c = new Choice();
	Button btn = new Button("Add items");
	int count = 0;

	public void init() {
		tf.setEditable(true);
		for (int i = 0; i < 3; i++) {
			c.addItem(desc[count++]);
		}
		add(tf);
		add(btn);
		add(c);
	}

	public boolean action(Event evt, Object obj) {
		if (evt.target.equals(c)) {
			tf.setText("index:" + c.getSelectedIndex() + " " + (String) obj);
		} else if (evt.target.equals(btn)) {
			if (count < desc.length)
				c.addItem(desc[count++]);
			// c.addItem(new String(S.valueOf(count++)));
		} else {
			return super.action(evt, obj);
		}
		return true;
	}
}
